//
//  BaseTableViewController.swift
//  DSWeibo
//
//  Created by silence on 16/1/27.
//  Copyright © 2016年 silence. All rights reserved.
//

import UIKit

class BaseTableViewController: UITableViewController , VisitorViewDelegate{

    // 定义一个变量保存用户是否登陆
    var userLogin = false
    
    // 定义属性保存未登录界面
    var visitorView: VisitorView?
    
    override func loadView() {
        userLogin ? super.loadView() : setupVisitorView()
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
    }

    // MARK: - 内部控制方法
    /**
     创建未登陆界面
     */
    private func setupVisitorView(){
        
        // 1.初始化未登录界面
        let customView = VisitorView()
        customView.delegate = self
        view = customView
        visitorView = customView
        
        // 2.设置导航条未登录按钮
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: self, action: "registerBtnWillClick")
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登陆", style: UIBarButtonItemStyle.Plain, target: self, action: "loginBtnWillClick")
        
    }
    
    //MARK:- VisitorViewDelegate
    
    func loginBtnWillClick() {
        print(__FUNCTION__)
    }
    
    func registerBtnWillClick() {
        print(__FUNCTION__)
    }
    
}
